#include "Level3.h"

Level3::Level3(void)
:moveTerrain(false)
,terrainMovement_x(0)
{
}

Level3::~Level3(void)
{
}

void Level3::InitLevel(Character *player, QUESTTYPE questType, int difficulty)
{
	if(!init)
	{
		//1st Level
		//Base floor
		this->CreatePlatform(Vector3D(-210, 500, 0), 15, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Right boundary
		this->CreatePlatform(Vector3D(-290, 417, 0), 5, 1, Platform::TREE, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(-325, 417, 0), 5, 1, Platform::TREE, 1.0, 1.0, 1.0);

		//hay
		this->CreatePlatform(Vector3D(150, 465, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(175, 430, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(215, 465, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		
		//Ai
		this->CreatePlatform(Vector3D(300, 460, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(600, 460, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//stairs
		this->CreatePlatform(Vector3D(300, 410, 0), 2, 1, Platform::GRASS, 1.0, 1.0, 1.0);
		
		// Level 2 //
		//Base
		this->CreatePlatform(Vector3D(800, 465, 0), 20, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Ai
		this->CreatePlatform(Vector3D(900, 425, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//Tree
		this->CreatePlatform(Vector3D(1080, 385, 0), 3, 1, Platform::TREE, 1.0, 1.0, 1.0);

		//stairs
		this->CreatePlatform(Vector3D(682, 420, 0), 1, 1, Platform::GRASS, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(800, 375, 0), 1, 1, Platform::GRASS, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(920, 340, 0), 6, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Ai
		this->CreatePlatform(Vector3D(1000, 300, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1300, 300, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		// floor
		this->CreatePlatform(Vector3D(1490, 350, 0), 6, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Ai
		this->CreatePlatform(Vector3D(1550, 310, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1800, 310, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//Hay
		this->CreatePlatform(Vector3D(1350, 430, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1375, 395, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1415, 430, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		
		//AI
		this->CreatePlatform(Vector3D(1500, 425, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1700, 425, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(1900, 425, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//Lamp
		this->CreatePlatform(Vector3D(2100, 330, 0), 1, 1, Platform::LAMP, 1.0, 1.0, 1.0);

		// floor
		this->CreatePlatform(Vector3D(1950, 310, 0), 2, 1, Platform::GRASS, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(2090, 270, 0), 7, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Ai
		this->CreatePlatform(Vector3D(2150, 230, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(2500, 230, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		
		//Hay
		this->CreatePlatform(Vector3D(2350, 235, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(2415, 235, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);

		// FLOOR //
		this->CreatePlatform(Vector3D(2580, 320, 0), 25, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Hay
		this->CreatePlatform(Vector3D(2650, 285, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(2715, 285, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);

		//floor
		this->CreatePlatform(Vector3D(2750, 240, 0), 4, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//AI
		this->CreatePlatform(Vector3D(2800, 200, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//Tree
		this->CreatePlatform(Vector3D(2900, 158, 0), 2, 1, Platform::TREE, 1.0, 1.0, 1.0);

		//Ai
		this->CreatePlatform(Vector3D(2800, 280, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(3000, 280, 0), 1, 1, Platform::AISPAWNPOINT, 1.0, 1.0, 1.0);

		//Boundary if the level is not protect
		if (questType == Level::PROTECT)
		{
			//Hay
			this->CreatePlatform(Vector3D(3150, 285, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
			this->CreatePlatform(Vector3D(3200, 250, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
			this->CreatePlatform(Vector3D(3215, 285, 0), 1, 1, Platform::HAY, 1.0, 1.0, 1.0);
		}

		//Tree
		this->CreatePlatform(Vector3D(3300, 238, 0), 4, 1, Platform::TREE, 1.0, 1.0, 1.0);

		//Floor
		this->CreatePlatform(Vector3D(3300, 210, 0), 4, 1, Platform::GRASS, 1.0, 1.0, 1.0);

		//Special Ai
		this->CreatePlatform(Vector3D(3600, 280, 0), 1, 1, Platform::SPECIALSPAWN, 1.0, 1.0, 1.0);
		this->CreatePlatform(Vector3D(3900, 280, 0), 1, 1, Platform::SPECIALSPAWN, 1.0, 1.0, 1.0);

		//Tree
		this->CreatePlatform(Vector3D(4000, 238, 0), 3, 1, Platform::TREE, 1.0, 1.0, 1.0);
		
		Level::InitLevel(player, questType, difficulty);

		init = true;
	}
}

void Level3::TerrainAnimation(void)
{
	if (moveTerrain == false)
	{
		terrainMovement_x += (20 * FrameTime);

		if (terrainMovement_x >= 10)
		{
			moveTerrain = true;
		}
	}
	else if(moveTerrain == true)
	{
		terrainMovement_x -= (20 * FrameTime);

		if (terrainMovement_x <= -10)
		{
			moveTerrain = false;
		}
	}
}

void Level3::RenderLevel(void)
{
	Level::RenderLevel();
}

bool Level3::UpdateLevel(float elapsed)
{
	return Level::UpdateLevel(elapsed);
}